#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2020/2/24 14:47
# @Author  : HaoXuan
# @Email   : 879316712@qq.com
# @File    : 爬取Girl-Picture.py
# @Software: PyCharm

import requests
import re
#请求地址
url = 'http://image.baidu.com/search/index'
#请求头部信息
headers = {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    #用户信息
    'Cookie': 'winWH=%5E6_1920x937; BDIMGISLOGIN=0; BIDUPSID=1141D5A7CC658A5BE581AA82F60B8EAB; PSTM=1583216893; BAIDUID=1141D5A7CC658A5B8F57BDDDC97EC604:FG=1; BDRCVFR[VXHUG3ZuJnT]=mk3SLVN4HKm; delPer=0; PSINO=6; H_PS_PSSID=; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; BDRCVFR[dG2JNJb_ajR]=mk3SLVN4HKm; BDRCVFR[X_XKQks0S63]=mk3SLVN4HKm; userFrom=cn.bing.com; firstShowTip=1; indexPageSugList=%5B%22%E7%BE%8E%E5%A5%B3%22%5D; cleanHistoryStatus=0',
    #请求地址
    'Host': 'image.baidu.com',
    #来源地址
    'Referer': 'http://image.baidu.com/',

    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36'
}
# data = {
# tn: baiduimage
# ipn: r
# ct: 201326592
# cl: 2
# lm: -1
# st: -1
# fm: index
# fr:
# hs: 0
# xthttps: 111111
# sf: 1
# fmq:
# pv:
# ic: 0
# nc: 1
# z:
# se: 1
# showtab: 0
# fb: 0
# width:
# height:
# face: 0
# istype: 2
# ie: utf-8
# word: 美女
# }

#使用requests进行请求 图片地址
response = requests.get(url,headers=headers).text
#使用正则匹配数据，匹配所有的并且有多个
#https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1564154457,2160326790&fm=26&gp=0.jpg
reg = re.compile('https://.jpg')